﻿using System;

namespace Borg.AddOn
{
    [Serializable]
    internal sealed class TypeStoreNotificationHookChain : ITypeStoreNotificationHook
    {
        private readonly ITypeStoreNotificationHook[] _hooks;

        public TypeStoreNotificationHookChain(ITypeStoreNotificationHook[] hooks)
        {
            _hooks = hooks;
        }

        public void Init(ITypeStoreModifier modifier)
        {
            foreach (ITypeStoreNotificationHook hook in _hooks)
                hook.Init(modifier);
        }

        public void OnContractAdded(Contract contract)
        {
            foreach (ITypeStoreNotificationHook hook in _hooks)
                hook.OnContractAdded(contract);
        }

        public void OnContractRemoved(Contract contract)
        {
            foreach (ITypeStoreNotificationHook hook in _hooks)
                hook.OnContractRemoved(contract);
        }

        public void OnPluginAdded(Plugin plugin)
        {
            foreach (ITypeStoreNotificationHook hook in _hooks)
                hook.OnPluginAdded(plugin);
        }

        public void OnPluginRemoved(Plugin plugin)
        {
            foreach (ITypeStoreNotificationHook hook in _hooks)
                hook.OnPluginRemoved(plugin);
        }
    }
}

